This file and its intellectual contents are considered property of the creator and are to be treated as such with respect to use in other applications. Any use of this software for any purpose whatsoever must have explicit permission from the author of the file. This code is part of an ongoing development process for future possible products, and so is considered private property.
Do not use without permission. Author: Scott C. Ziegler <Aslan@Narnia.net>
Instructions for use:
This program is used as an interface by which to textually control programs on a
prompt-response basis. The following functions provide the behaviors to integrate its
use with user-defined classes, allowing for testing and use.
The functions:
String getLine() - waits for user input to be entered at the prompt, and returns the
entered string.
void printLine(String s) - prints the string s and provides a newline ("\n")
void printEndLine(String s) - prints the string s and gives a newline and
a user prompt. (">")
void print(String s) - appends the string s with no newline.
void endLine() - appends a newline and a user prompt. (to be used in combination
with print(String s).)
Code in use by:
FileTester
DiceTester
SpellCompositor
vers. history:
05.16.00 - Corrected the default button nonsense to just an action of the JTextField
07.20.00 - Declared the project Syntactically Correct as stands.
07.20.00 - added functionality for interaction with other classes.
i.e. getLine()/printLine(), etc.
07.20.00 - removed all old debugging code.
07.24.00 - added feature that scrolls viewpane as new text appears.
07.24.00 - integrated BasicWindowMonitor into the class file.
09.27.00 - changed implementation of print statements to differentiate between
printing a system prompt or a user prompt, making the system prompt
a optional string or no string. Added print(), printEndLine(), endLine(),
and newLine().
06.12.01 - began work on the OSX version of this app.
Work needed:
- need a method of scripting commands from a file or a series of text inputs or text input format
- need accessors to add/remove menuItems
- Panel of buttons and lists to clear and to access history
- fix the text field to be as large as the width minus the button always.
Work Completed:
found function (JButton.doClick(int millisecs)) to activate button to prevent redundancy
examine focus to be always returned to the text field. -Finished ??.??.??
discover why the default button is not working... -Finished 05.16.00
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.Window;
import java.util.*;
import java.io.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
public class InteractionFrame extends JFrame {
public static final String DEFAULT_SYS_PROMPT = "Sys: ";
JScrollPane scrollingRegion;
JTextArea textDisplayRegion;
JTextField textEntryRegion;
JButton executeButton;
JPanel commandPanel;
JRootPane root;
JFileChooser scriptChooser;
JFrame frame;
JMenuBar menuBar;
JMenu fileMenu;
JMenuItem aboutBoxMenuItem;
JMenuItem quitMenuItem;
JMenuItem runScriptMenuItem;
JMenu editMenu;
JMenuItem undoMenuItem;
JMenuItem cutMenuItem;
JMenuItem copyMenuItem;
JMenuItem pasteMenuItem;
JMenu optionsMenu;
JCheckBoxMenuItem promptCBMenuItem;
File scriptFile;
boolean scriptMode;
Vector scriptVector;
Enumeration scriptEnumeration;
Font systemFont;
Font inputFont;
String commandString;
boolean validString;
String sysPrompt;
boolean sysPromptSwitch;
JScrollBar jsb;
BoundedRangeModel scrollModel;
int oldMax;
public InteractionFrame() {
super ("Mentat for MacHack 2001 fnord"); // this was hacked in at the last moment